package com.cwj;

import org.apache.commons.collections4.map.LRUMap;

/**
 * @author chenwujie
 * @date 2021-01-08 15:55
 */
public class LRUMapTest {
    public static void main(String[] args) {
        LRUMap<String, String> lruMap = new LRUMap<>(3);
        lruMap.put("1", "A1");
        lruMap.put("2", "B1");
        lruMap.put("2", "B2");
        lruMap.put("3", "C1");
        lruMap.put("3", "C2");
        lruMap.put("3", "C3");
        lruMap.put("4", "D1");
        lruMap.put("5", "E1");
        lruMap.put("6", "K1");

//        String lastKey = lruMap.lastKey();
//        String firstKey = lruMap.firstKey();
//        System.out.println("last: " + lastKey + lruMap.get(lastKey));
//        System.out.println("firstKey: " + firstKey + lruMap.get(firstKey));

        lruMap.forEach((k, v) -> {
            System.out.println(k + v);
        });
    }
}
